Skip to content

Conversation

@msslulu
Copy link
Contributor

@msslulu msslulu commented Dec 25, 2025

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features
    • Added a vector-based AI search endpoint so users can perform semantic searches across stored collections and receive ranked matching results for improved content discovery and retrieval.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 25, 2025

Walkthrough

Adds a vector search API endpoint /ai/search to AiChatController, injecting a StorageService and a POST handler that accepts SearchRequest and returns Result<List<EmbeddingMatchDto>> by delegating to vectorStorageService.search(searchDto).

Changes

Cohort / File(s) Summary
Vector Search Endpoint
base/src/main/java/com/tinyengine/it/controller/AiChatController.java
Added @Autowired private StorageService vectorStorageService;, new POST endpoint /ai/search with public Result<List<EmbeddingMatchDto>> searchInCollection(@RequestBody SearchRequest searchDto) delegating to vectorStorageService.search(searchDto) and returning Result.success(...); added imports for EmbeddingMatchDto, SearchRequest, StorageService, List.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant AiChatController
    participant StorageService
    participant VectorStore as "Vector DB / Store"
    rect rgb(230,248,255)
    Client->>AiChatController: POST /ai/search (SearchRequest)
    end
    AiChatController->>StorageService: search(SearchRequest)
    StorageService->>VectorStore: vector similarity query
    VectorStore-->>StorageService: List<EmbeddingMatchDto>
    StorageService-->>AiChatController: List<EmbeddingMatchDto>
    AiChatController-->>Client: Result.success(List<EmbeddingMatchDto>)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I hop through vectors, sniffing each thread,

I fetch little matches from embeddings spread,
A StorageService hums and hands them back bright,
Results wrapped in success, returned to the light,
Hooray — searches now swift in a single flight!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The PR title 'fix: add ai/search endpoint' accurately summarizes the main change - adding a new API endpoint for vector-based search functionality.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
base/src/main/java/com/tinyengine/it/controller/AiChatController.java (1)

59-63: Field injection is acceptable, but constructor injection is preferred.

The field injection works correctly. However, as an optional improvement, consider using constructor injection instead, which makes dependencies explicit, facilitates testing, and prevents potential issues with field injection in certain frameworks.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 887f1b6 and bbc21de.

📒 Files selected for processing (1)
  • base/src/main/java/com/tinyengine/it/controller/AiChatController.java

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
base/src/main/java/com/tinyengine/it/controller/AiChatController.java (2)

74-76: Note: Formatting consistency already flagged.

The formatting changes to these @ApiResponse annotations have already been noted by another reviewer regarding code indentation style consistency with the project.

Also applies to: 113-115, 148-150


179-181: Authorization header concern already raised.

A previous review comment already noted that this endpoint is missing the Authorization header parameter that other endpoints in this controller accept. Please address that feedback.

🧹 Nitpick comments (1)
base/src/main/java/com/tinyengine/it/controller/AiChatController.java (1)

179-181: Add throws Exception for consistency with other endpoints.

All other endpoints in this controller declare throws Exception in their method signatures (lines 81, 120, 154). Consider adding it here for consistency:

public Result<List<EmbeddingMatchDto>> searchInCollection(@RequestBody SearchRequest searchDto) throws Exception {

This maintains a uniform error-handling contract across the controller.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd750f8 and bd4167b.

📒 Files selected for processing (1)
  • base/src/main/java/com/tinyengine/it/controller/AiChatController.java

@hexqi hexqi changed the title feat:add AIChat endpoint fix: add ai/search endpoint Dec 26, 2025
@hexqi hexqi merged commit b688c67 into opentiny:develop Dec 26, 2025
1 check passed
msslulu added a commit to msslulu/tiny-engine-backend-java that referenced this pull request Dec 26, 2025
hexqi pushed a commit that referenced this pull request Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants